package com.zyy.zyy.controller;

import com.alibaba.fastjson.JSON;
import com.zyy.zyy.bean.User;
import com.zyy.zyy.dao.LoginMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

/**
 * Create by chenlipeng on 2021/08/20 10:35
 */
@RestController
public class LoginController {
    
    @Autowired
    LoginMapper loginMapper;
    @RequestMapping("/login")
    public String login(@RequestBody User user){
        String flag="error";
        User user1=loginMapper.getUser(user.getUsername(),user.getPassword());
        HashMap<String,Object> res=new HashMap();
        if (user1!=null){
            flag="ok";
        }
        res.put("flag",flag);
        res.put("user",user1);
        String res_String= JSON.toJSONString(res);
        return res_String;
    }
}
